import { ChanceData, MoneyEnum, PriceType } from "../基础配置";
import { Base } from "./基础属性"
import { AddPoint } from "./元素属性"
import { Custom } from "./自定义属性"
import { skill } from "./附加技能"
//极品属性
// 防御上限 下限
// 魔域上限 下限
// 攻魔道 上限 下限
// export const ItemBaseList = [
//     {
//         name: 'AddAC',
//         text: "防御上限"
//     },
//     {
//         name: 'AddLAC',
//         text: "防御下限"
//     },
//     {
//         name: 'AddMAC',
//         text: "魔御上限"
//     },
//     {
//         name: 'AddLMAC',
//         text: "魔御下限"
//     },
//     {
//         name: 'AddDC',
//         text: "攻击上限"
//     },
//     {
//         name: 'AddLDC',
//         text: "攻击下限"
//     },
//     {
//         name: 'AddMC',
//         text: "魔法上限"
//     },
//     {
//         name: 'AddLMC',
//         text: "魔法下限"
//     },
//     {
//         name: 'AddSC',
//         text: "道术上限"
//     },
//     {
//         name: 'AddLSC',
//         text: "道术下限"
//     },
// ]



//装备自带元素属性
// 固定HP 13
// 固定MP 14
// 百分比HP 16
// 百分比MP 17
// 致命几率 4
// 致命伤害 18 
// 致命抵抗 21
// 经验加成 8
// 金币加成 10

export enum ItemAddPointEnum {
    固定HP = 13,
    固定MP = 14,
    百分比HP = 16,
    百分比MP = 17,
    致命几率 = 4,
    致命伤害 = 18,
    致命抵抗 = 21,
    经验加成 = 8,
    金币加成 = 10
}

export const ItemAddPointList = [
    {
        index: 13,
        text: "固定HP"
    },
    {
        index: 14,
        text: "固定MP"
    },
    {
        index: 16,
        text: "百分比HP"
    },
    {
        index: 17,
        text: "百分比MP"
    },
    {
        index: 4,
        text: "致命几率"
    },
    {
        index: 18,
        text: "致命伤害"
    },
    {
        index: 21,
        text: "致命抵抗"
    },
    {
        index: 8,
        text: "经验加成"
    },
    // {
    //     index: 10,
    //     text: "金币加成"
    // }

]

//自定义属性
export enum ItemCustomEnum {
    DamageAdd,//固定伤害
    DamageCut,//格挡
    DamageAddPer,//伤害增加百分比
    DamageCutPer,//伤害减少百分比
    DamageBack,//伤害反弹值
    DamageBackPer,//伤害反弹比例

    MonDamageAdd,//怪物固定伤害
    MonDamageCut,//怪物格挡
    MonDamageAddPer,//怪物伤害增加百分比
    MonDamageCutPer,//怪物伤害减少百分比

    ShieldDamage,//对魔法盾的额外伤害
    ShieldDamagePer,//对魔法盾的额外伤害

    SlaveDis,// 宝宝射程
    SlaveDamageAdd,// 宝宝固定伤害
    SlaveDamageAddPer,// 宝宝伤害百分比
    SlaveDamageCutPer,// 宝宝减伤
    SlaveDamageCut,// 宝宝格挡
    SlaveNum,// 宝宝数量
    SlaveAddAbilityPer,// 宝宝属性继承倍率
    SlaveAddLevel,// 宝宝增加的初始等级
    SlaveAddMaxLevel,// 宝宝增加的等级上限

    AddSkill, //附加技能,

    Check = 40,//是否鉴定
}

//最大属性
export const ItemCustomSet = [
    {
        max: 600,
        text: "固定伤害",
    },
    {
        max: 600,
        text: "格挡",
    },
    {
        max: 1200,
        text: "伤害增加",
    },
    {
        max: 1200,
        text: "伤害吸收",
    },
    {
        max: 600,
        text: "伤害反弹值",
    },
    {
        max: 360,
        text: "伤害反弹比例",
    },
    {
        max: 600,
        text: "怪物固定伤害",
    },
    {
        max: 600,
        text: "怪物格挡",
    },
    {
        max: 1200,
        text: "怪物伤害增加",
    },
    {
        max: 1200,
        text: "怪物伤害吸收",
    },
    {
        max: 500,
        text: "破盾固伤",
    },
    {
        max: 500,
        text: "破盾伤害",
    },
    {
        max: 4,
        text: "宝宝射程",
    },
    {
        max: 500,
        text: "宝宝固定伤害",
    },
    {
        max: 500,
        text: "宝宝格挡",
    },
    {
        max: 1500,
        text: "宝宝伤害增加",
    },
    {
        max: 1500,
        text: "宝宝伤害吸收",
    },
    {
        max: 5,
        text: "宝宝数量",
    },
    {
        max: 5000,
        text: "宝宝属性继承倍率",
    },
    {
        max: 1200,
        text: "宝宝初始等级",
    },
    {
        max: 1000,
        text: "宝宝等级上限",
    },
]

// 伤害增加
// 伤害吸收
// 伤害反弹比例
// 伤害反弹固定值
// 固定伤害
// 格挡

// 怪物伤害百分比
// 怪物固定伤害
// 怪物减伤百分比
// 怪物格挡

// 魔法盾额外伤害固定
// 魔法盾额外伤害百分比

// 宝宝射程
// 宝宝伤害百分比
// 宝宝固定伤害
// 宝宝减伤
// 宝宝格挡
// 宝宝数量
// 宝宝属性继承倍率
// 宝宝等级
// 宝宝等级上限

// 附加技能

//鉴定价格1
const CheckPrice1 = [
    [
        {
            type: PriceType.ItemType,
            name: 0,
            num: 2
        }
    ],
    [
        {
            type: PriceType.ItemType,
            name: 1,
            num: 2
        }
    ],
    [
        {
            type: PriceType.ItemType,
            name: 2,
            num: 2
        }
    ],
    [
        {
            type: PriceType.ItemType,
            name: 3,
            num: 2
        }
    ],
    [
        {
            type: PriceType.ItemType,
            name: 4,
            num: 2
        }
    ],
    [
        {
            type: PriceType.ItemType,
            name: 5,
            num: 2
        }
    ],
    [
        {
            type: PriceType.ItemType,
            name: 6,
            num: 2
        }
    ],
    [
        {
            type: PriceType.ItemType,
            name: 7,
            num: 2
        }
    ],
]

//鉴定价格2
const CheckPrice2 = [
    [
        {
            type: PriceType.Money,
            name: MoneyEnum.GameGold,
            num: 10
        },
    ],
    [
        {
            type: PriceType.Money,
            name: MoneyEnum.GameGold,
            num: 26
        },
    ],
    [
        {
            type: PriceType.Money,
            name: MoneyEnum.GameGold,
            num: 52
        },
    ],
    [
        {
            type: PriceType.Money,
            name: MoneyEnum.GameGold,
            num: 104
        },
    ],
    [
        {
            type: PriceType.Money,
            name: MoneyEnum.GameGold,
            num: 200
        },
        {
            type: PriceType.ItemType,
            name: 3,
            num: 2
        }
    ],
    [
        {
            type: PriceType.Money,
            name: MoneyEnum.GameGold,
            num: 400
        },
        {
            type: PriceType.ItemType,
            name: 4,
            num: 2
        }
    ],
    [
        {
            type: PriceType.Money,
            name: MoneyEnum.GameGold,
            num: 800
        },
        {
            type: PriceType.ItemType,
            name: 5,
            num: 2
        }
    ],
    [
        {
            type: PriceType.Money,
            name: MoneyEnum.GameGold,
            num: 1600
        },
        {
            type: PriceType.ItemType,
            name: 6,
            num: 2
        }
    ],
]

export const CheckPrice = [CheckPrice1, CheckPrice2];

export enum CheckType {
    All,//所有
    Base,//极品属性
    AddPoint,//附加属性
    Custom,//自定义属性
}

const chanceNumberList = [220, 360, 440, 480, 500]

function produceChanceItem(maxValue: number, chanceNumber?: Array<number>): Array<ChanceData> {
    chanceNumber = chanceNumber || chanceNumberList
    let minValue = Math.floor(maxValue / 3)
    let space = (maxValue - minValue) / chanceNumber.length
    space = Math.max(1, space)
    // console.log(maxValue + " " + minValue + " " + space)


    let chanceList = new Array<ChanceData>(chanceNumber.length);
    let j = 0;
    for (let i = chanceList.length - 1; i >= 0; i--) {
        let num = chanceNumber[i];

        let min = maxValue - Math.ceil(j * space + space) + 1
        let max = maxValue - Math.ceil(j * space)

        j++;

        min = Math.max(min, 1)
        max = Math.max(max, 1)

        let item = {
            min: min,
            max: max,
            chance: num,
        } as ChanceData;
        chanceList[i] = item;
    }


    return chanceList
}

export function produceChanceList(maxValue: number, maxLv: number, chanceNumber?: Array<number>): Array<Array<ChanceData>> {
    let space = maxValue / maxLv
    space = Math.max(1, space)
    let chanceList = new Array<Array<ChanceData>>(maxLv);
    let num = maxValue;
    let j = 0;
    for (let i = maxLv - 1; i >= 0; i--) {
        chanceList[i] = produceChanceItem(num, chanceNumber)
        j++;
        num = maxValue - Math.floor(j * space);
        num = Math.max(1, num)
    }

    return chanceList
}



export const ItemCheckSet = {
    Base,
    AddPoint,
    CustomNum: [
        3, 4, 4, 5, 6, 6, 7, 8
    ],
    Custom,
    skill
}
